package com.saasitems.admin.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.saasitems.admin.dao.MattsMapper;
import com.saasitems.admin.dao.MediaResMapper;
import com.saasitems.admin.dao.OriginalMapper;
import com.saasitems.admin.model.Matts;
import com.saasitems.admin.model.MediaRes;
import com.saasitems.admin.model.Original;
import com.saasitems.admin.model.OriginalExample;
import com.saasitems.admin.web.vo.original.OriginalQueryVO;
import com.saasitems.common.model.PageInfo;
import com.saasitems.common.utils.UUIDGenerator;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2017/4/11.
 */
@Service
@Transactional(readOnly = true)
public class MediaResService {

    @Autowired
    private MediaResMapper mediaResMapper;

    @Transactional(readOnly=false)
    public String saveMediaRes(String fileName, String extName, long fileSize) {
        String uuid = UUIDGenerator.getUUID();
        MediaRes record = new MediaRes();
        record.setId(uuid);
        record.setFileName(fileName);
        record.setFileExt(extName);
        record.setFileSize((int) fileSize);
        record.setWidth(0);
        record.setHeight(0);
        record.setCreTime(new Date());
        mediaResMapper.insert(record);
        return uuid;
    }

}
